import { create } from 'zustand'

type State = {
  tabKey: string
  backUp: boolean
  data_item_id: number | null
  data_item_infor: object
  table_name: string
  state: string
  setp1Save: boolean
}

type Actions = {
  setTabKey: (qty: string) => void
  setBackUp: (qty: boolean) => void
  setDataItemId: (qty: number | null) => void
  setDataItemInfor: (qty: object) => void
  setTableName: (qty: string) => void
  setState: (qty: string) => void
  setSetp1Save: (qty: boolean) => void
}

export const useTypeStore = create<State & Actions>((set) => ({
  tabKey: '1',
  backUp: false,
  data_item_id: null,
  data_item_infor: {},
  table_name: '',
  state: '',
  setp1Save: false,
  setTabKey: (value: string) => set(() => ({ tabKey: value })),
  setBackUp: (value: boolean) => set(() => ({ backUp: value })),
  setDataItemId: (value: number | null) => set(() => ({ data_item_id: value })),
  setDataItemInfor: (value: object) => set(() => ({ data_item_infor: value })),
  setTableName: (value: string) => set(() => ({ table_name: value })),
  setState: (value: string) => set(() => ({ state: value })),
  setSetp1Save: (value: boolean) => set(() => ({ setp1Save: value }))
}))
